<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>内部账号管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" type="text/css" href="assets/layui/css/layui.css" />
</head>
<body class="in-account">
	<span class="layui-breadcrumb">
	    <a>系统管理</a>
		  <a><cite>内部账号管理</cite></a>
	</span>
	<div class="layui-fluid">
			<div class="carTable">
				<div class="layui-inline">
					<input type="text" name="content" placeholder="搜索" autocomplete="off" class="layui-input" id="searchContent">
				</div>
				<button class="layui-btn" data-type="reload">搜索</button>
			</div>
		<table class="layui-hide" id="in-account-table" lay-filter="inaccount"></table>
		<script type="text/html" id="checkInfor">
			<a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
		</script>
		<button class="layui-btn" id="createinAccount">创建账号</button>
	</div>
	<script src="assets/layui/layui.js" type="text/javascript"></script>
	<script type="text/javascript" src="assets/js/all.js"></script>
	<script>
		layui.use(['form', 'table', 'laypage', 'layer'], function() {
			var form = layui.form,
				table = layui.table,
				laypage = layui.laypage,
				layer = layui.layer,
				$ = layui.$
			//方法级渲染
			var tableIn = table.render({
				elem: '#in-account-table',
				url: 'assets/data/account.json',
				cols: [
					[{
						field: 'id',
						title: '账号',
						width: 80
					}, {
						field: 'phone',
						title: '联系方式',
						width: 130
					}, {
						field: 'email',
						title: 'Email',
						width: 130
					}, {
						field: 'company',
						title: '企业名称'
					}, {
						field: 'sign',
						title: '身份'
					}, {
						field: 'experience',
						title: '权限'
					}, {
						//fixed: 'right',
						align: 'center',
						toolbar: '#checkInfor'
					}]
				],
				id: 'testReload',
				page: true,
				group: 3,
				done: function(res, curr, count) { //res即为你接口返回的信息,curr 是当前页，count总页数
					if(res.code == 0) {
						layer.msg(res.msg);
					}
					if(res.code == 1) {

					}
				}
			});
			$('.in-account .layui-btn').on('click', function() {
				var searchContent = $('#searchContent').val()
				//执行重载
				table.reload('testReload', {
					page: {
						curr: 1 //重新从第 1 页开始
					},
					where: {
						key: searchContent
					}
				});
			});
			//监听工具条
			table.on('tool(inaccount)', function(obj) {
				var data = obj.data;
				if(obj.event === 'detail') {
					var index = layer.open({
						type: 2,
						title: '账号信息',
						area: ['700px', '450px'],
						fixed: false, //不固定
						maxmin: true,
						content: 'addNewAccount.html'
					});
					layer.full(index);

				} else if(obj.event === 'del') {
					layer.confirm('真的删除此行信息么', function(index) {
						obj.del();
						layer.close(index);
					});
				}
				//  else if(obj.event === 'edit'){
				//    layer.msg('ID：'+ data.id + ' 的查看操作');
				//  }
			});
			//添加新内部账号
			$("#createinAccount").on("click", function() {
				var index = layer.open({
					type: 2,
					title: '账号信息',
					area: ['700px', '450px'],
					fixed: false, //不固定
					maxmin: true,
					content: 'addNewAccount.html'
				});
				layer.full(index);
			});
		})
	</script>
</body>
</html>